package com.sina.weibo;

import android.app.PendingIntent;
import android.app.Service;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Handler;
import android.os.IBinder;
import android.text.TextUtils;
import android.util.Log;
import android.widget.RemoteViews;
import com.sina.weibo.models.MBlog;
import com.sina.weibo.models.User;
import java.io.File;
import java.util.List;

public class WeiboWidgetProvider extends AppWidgetProvider
{
  static final ComponentName THIS_WIDGET = new ComponentName("com.sina.weibo", "com.sina.weibo.WeiboWidgetProvider1");

  public void onDisabled(Context paramContext)
  {
    Intent localIntent = new Intent(paramContext, WeiboWidgetService.class);
    boolean bool = paramContext.stopService(localIntent);
    super.onDisabled(paramContext);
  }

  public void onEnabled(Context paramContext)
  {
    super.onEnabled(paramContext);
    Intent localIntent = new Intent(paramContext, WeiboWidgetService.class);
    ComponentName localComponentName = paramContext.startService(localIntent);
  }

  public void onUpdate(Context paramContext, AppWidgetManager paramAppWidgetManager, int[] paramArrayOfInt)
  {
    super.onUpdate(paramContext, paramAppWidgetManager, paramArrayOfInt);
    Intent localIntent = new Intent(paramContext, WeiboWidgetService.class).setAction("com.sina.weibo.service.action.ACTION_LOADING");
    ComponentName localComponentName = paramContext.startService(localIntent);
  }

  public class WeiboWidgetService extends Service
  {
    public static final String ACTION_DOWN_BLOG = "com.sina.weibo.service.action.ACTION_DOWN_BLOG";
    public static final String ACTION_INIT_LOADING = "com.sina.weibo.service.action.ACTION_LOADING";
    public static final String ACTION_LOGIN = "com.sina.weibo.service.action.ACTION_LOGIN";
    public static final String ACTION_REFRESH_CACHE = "com.sina.weibo.service.action.ACTION_REFRESH_CACHE";
    public static final String ACTION_UP_BLOG = "com.sina.weibo.service.action.ACTION_UP_BLOG";
    private static final long DELAY_MILLIS = 7000L;
    public static final String EXTRA_CACHE_PATH = "com.sina.weibo.service.extra.EXTRA_CACHE_PATH";
    public static final String EXTRA_USR = "com.sina.weibo.service.extra.EXTRA_USR";
    protected static final int WHAT_UPDATE = 900;
    private static boolean hasCacheDir = 0;
    private static String mCacheDir;
    private static User mUser;
    private MBlog currBlog;
    private Handler handler;
    private boolean handlerRunning = 0;
    private BroadcastReceiver initReceiver;
    public BroadcastReceiver noUserReceiver;

    private RemoteViews initLoginViews()
    {
      String str1 = getPackageName();
      RemoteViews localRemoteViews = new RemoteViews(str1, 2130903095);
      localRemoteViews.setViewVisibility(2131624203, 0);
      localRemoteViews.setViewVisibility(2131624206, 8);
      localRemoteViews.setViewVisibility(2131624209, 8);
      String str2 = getString(2131427578);
      localRemoteViews.setTextViewText(2131624205, str2);
      String str3 = getString(2131427550);
      localRemoteViews.setTextViewText(2131624204, str3);
      Intent localIntent1 = new Intent();
      Context localContext = getApplicationContext();
      Intent localIntent2 = localIntent1.setClass(localContext, MainTabActivity.class);
      PendingIntent localPendingIntent = PendingIntent.getActivity(this, 0, localIntent2, 268435456);
      localRemoteViews.setOnClickPendingIntent(2131624204, localPendingIntent);
      return localRemoteViews;
    }

    private RemoteViews initProgressViews()
    {
      String str = getPackageName();
      RemoteViews localRemoteViews = new RemoteViews(str, 2130903095);
      localRemoteViews.setViewVisibility(2131624206, 0);
      localRemoteViews.setViewVisibility(2131624203, 8);
      localRemoteViews.setViewVisibility(2131624209, 8);
      return localRemoteViews;
    }

    private RemoteViews initRefreshViews()
    {
      String str1 = getPackageName();
      RemoteViews localRemoteViews = new RemoteViews(str1, 2130903095);
      localRemoteViews.setViewVisibility(2131624203, 0);
      localRemoteViews.setViewVisibility(2131624206, 8);
      localRemoteViews.setViewVisibility(2131624209, 8);
      String str2 = getString(2131427579);
      localRemoteViews.setTextViewText(2131624205, str2);
      String str3 = getString(2131427408);
      localRemoteViews.setTextViewText(2131624204, str3);
      Intent localIntent1 = new Intent();
      Context localContext = getApplicationContext();
      Intent localIntent2 = localIntent1.setClass(localContext, WeiboWidgetService.class).setAction("com.sina.weibo.service.action.ACTION_REFRESH_CACHE");
      PendingIntent localPendingIntent = PendingIntent.getService(this, 0, localIntent2, 0);
      localRemoteViews.setOnClickPendingIntent(2131624204, localPendingIntent);
      return localRemoteViews;
    }

    private void loadUser()
    {
      if (!hasCacheDir)
      {
        hasCacheDir = 1;
        mCacheDir = getCacheDir().getPath();
      }
      mUser = Utils.loadUserFile(mCacheDir);
      if (mUser == null);
      for (User localUser = StaticInfo.mUser; ; localUser = mUser)
      {
        mUser = localUser;
        return;
      }
    }

    private void makeDownAction(int[] paramArrayOfInt)
    {
      new WeiboWidgetProvider.WeiboWidgetService.6(this, paramArrayOfInt).start();
    }

    private void makeUpAction(int[] paramArrayOfInt)
    {
      new WeiboWidgetProvider.WeiboWidgetService.5(this, paramArrayOfInt).start();
    }

    private void turnPage(int[] paramArrayOfInt, List<MBlog> paramList, boolean paramBoolean)
    {
      int i = paramList.size();
      int j = 0;
      if (j >= i)
      {
        label18: if ((paramBoolean) && (j <= 0))
          j = i;
        if (!paramBoolean)
        {
          int k = i - 1;
          if (j >= k)
            j = -1;
        }
        if (!paramBoolean)
          break label149;
      }
      label149: for (int m = j - 1; ; m = j + 1)
      {
        MBlog localMBlog1 = (MBlog)paramList.get(m);
        this.currBlog = localMBlog1;
        MBlog localMBlog2 = this.currBlog;
        RemoteViews localRemoteViews = updateContentFromBlog(localMBlog2);
        if (localRemoteViews != null)
          AppWidgetManager.getInstance(this).updateAppWidget(paramArrayOfInt, localRemoteViews);
        return;
        MBlog localMBlog3 = (MBlog)paramList.get(j);
        MBlog localMBlog4 = this.currBlog;
        if (localMBlog3.equals(localMBlog4))
          break label18;
        j += 1;
        break;
      }
    }

    private RemoteViews updateContentFromBlog(MBlog paramMBlog)
    {
      if (paramMBlog == null)
      {
        Object localObject1 = null;
        return localObject1;
      }
      RemoteViews localRemoteViews1 = new android/widget/RemoteViews;
      String str1 = getPackageName();
      RemoteViews localRemoteViews2 = localRemoteViews1;
      String str2 = str1;
      int j = 2130903095;
      localRemoteViews2.<init>(str2, j);
      RemoteViews localRemoteViews3 = localRemoteViews1;
      int k = 2131624203;
      int m = 8;
      localRemoteViews3.setViewVisibility(k, m);
      RemoteViews localRemoteViews4 = localRemoteViews1;
      int n = 2131624206;
      int i1 = 8;
      localRemoteViews4.setViewVisibility(n, i1);
      RemoteViews localRemoteViews5 = localRemoteViews1;
      int i2 = 2131624209;
      int i3 = 0;
      localRemoteViews5.setViewVisibility(i2, i3);
      String str3 = paramMBlog.nick;
      RemoteViews localRemoteViews6 = localRemoteViews1;
      int i4 = 2131624200;
      String str4 = str3;
      localRemoteViews6.setTextViewText(i4, str4);
      int i = 2131624202;
      String str5;
      if (TextUtils.isEmpty(paramMBlog.rtrootuid))
      {
        str5 = paramMBlog.content;
        label142: RemoteViews localRemoteViews7 = localRemoteViews1;
        int i5 = i;
        String str6 = str5;
        localRemoteViews7.setTextViewText(i5, str6);
        Intent localIntent1 = Utils.editNewBlog(getApplicationContext());
        Context localContext1 = getApplicationContext();
        int i6 = 0;
        Intent localIntent2 = localIntent1;
        int i7 = 268435456;
        PendingIntent localPendingIntent1 = PendingIntent.getActivity(localContext1, i6, localIntent2, i7);
        RemoteViews localRemoteViews8 = localRemoteViews1;
        int i8 = 2131624211;
        PendingIntent localPendingIntent2 = localPendingIntent1;
        localRemoteViews8.setOnClickPendingIntent(i8, localPendingIntent2);
        Intent localIntent3 = new Intent();
        Context localContext2 = getApplicationContext();
        Intent localIntent4 = localIntent3.setClass(localContext2, WeiboWidgetService.class).setAction("com.sina.weibo.service.action.ACTION_UP_BLOG");
        Context localContext3 = getApplicationContext();
        int i9 = 0;
        Intent localIntent5 = localIntent4;
        int i10 = 0;
        PendingIntent localPendingIntent3 = PendingIntent.getService(localContext3, i9, localIntent5, i10);
        RemoteViews localRemoteViews9 = localRemoteViews1;
        int i11 = 2131624194;
        PendingIntent localPendingIntent4 = localPendingIntent3;
        localRemoteViews9.setOnClickPendingIntent(i11, localPendingIntent4);
        Intent localIntent6 = new Intent();
        Context localContext4 = getApplicationContext();
        Intent localIntent7 = localIntent6.setClass(localContext4, WeiboWidgetService.class).setAction("com.sina.weibo.service.action.ACTION_DOWN_BLOG");
        Context localContext5 = getApplicationContext();
        int i12 = 0;
        Intent localIntent8 = localIntent7;
        int i13 = 0;
        PendingIntent localPendingIntent5 = PendingIntent.getService(localContext5, i12, localIntent8, i13);
        RemoteViews localRemoteViews10 = localRemoteViews1;
        int i14 = 2131624195;
        PendingIntent localPendingIntent6 = localPendingIntent5;
        localRemoteViews10.setOnClickPendingIntent(i14, localPendingIntent6);
        Intent localIntent9 = new Intent();
        Context localContext6 = getApplicationContext();
        Intent localIntent10 = localIntent9.setClass(localContext6, MainTabActivity.class).putExtra("MODE_KEY", 0);
        Context localContext7 = getApplicationContext();
        int i15 = 0;
        Intent localIntent11 = localIntent10;
        int i16 = 268435456;
        PendingIntent localPendingIntent7 = PendingIntent.getActivity(localContext7, i15, localIntent11, i16);
        RemoteViews localRemoteViews11 = localRemoteViews1;
        int i17 = 2131624214;
        PendingIntent localPendingIntent8 = localPendingIntent7;
        localRemoteViews11.setOnClickPendingIntent(i17, localPendingIntent8);
        if (mUser == null)
          break label638;
        String str7 = mCacheDir;
        User localUser1 = mUser;
        List localList = Utils.loadHomeListFile(str7, localUser1);
        if ((localList == null) || (localList.size() <= 0))
          break label630;
        Intent localIntent12 = new Intent();
        Context localContext8 = getApplicationContext();
        Intent localIntent13 = localIntent12.setClass(localContext8, DetailWeiboActivity.class);
        String str8 = "KEY_MBLOG";
        MBlog localMBlog = paramMBlog;
        Intent localIntent14 = localIntent13.putExtra(str8, localMBlog);
        User localUser2 = mUser;
        Intent localIntent15 = localIntent14.putExtra("KEY_MUSR", localUser2);
        Context localContext9 = getApplicationContext();
        int i18 = 0;
        Intent localIntent16 = localIntent15;
        int i19 = 268435456;
        PendingIntent localPendingIntent9 = PendingIntent.getActivity(localContext9, i18, localIntent16, i19);
        RemoteViews localRemoteViews12 = localRemoteViews1;
        int i20 = 2131624213;
        PendingIntent localPendingIntent10 = localPendingIntent9;
        localRemoteViews12.setOnClickPendingIntent(i20, localPendingIntent10);
      }
      while (true)
      {
        Object localObject2 = localRemoteViews1;
        break;
        str5 = paramMBlog.rtreason;
        break label142;
        label630: localRemoteViews1 = initRefreshViews();
        continue;
        label638: localRemoteViews1 = initRefreshViews();
      }
    }

    public IBinder onBind(Intent paramIntent)
    {
      return null;
    }

    public void onCreate()
    {
      super.onCreate();
      WeiboWidgetProvider.WeiboWidgetService.1 local1 = new WeiboWidgetProvider.WeiboWidgetService.1(this);
      this.handler = local1;
      IntentFilter localIntentFilter1 = new IntentFilter("sina.weibo.action.SWITCHUSERDONE");
      WeiboWidgetProvider.WeiboWidgetService.2 local2 = new WeiboWidgetProvider.WeiboWidgetService.2(this);
      this.initReceiver = local2;
      Intent localIntent1 = registerReceiver(local2, localIntentFilter1);
      IntentFilter localIntentFilter2 = new IntentFilter("sina.weibo.action.NOUSER");
      WeiboWidgetProvider.WeiboWidgetService.3 local3 = new WeiboWidgetProvider.WeiboWidgetService.3(this);
      this.noUserReceiver = local3;
      Intent localIntent2 = registerReceiver(local3, localIntentFilter2);
    }

    public void onDestroy()
    {
      mUser = null;
      this.currBlog = null;
      BroadcastReceiver localBroadcastReceiver1 = this.initReceiver;
      unregisterReceiver(localBroadcastReceiver1);
      BroadcastReceiver localBroadcastReceiver2 = this.noUserReceiver;
      unregisterReceiver(localBroadcastReceiver2);
      super.onDestroy();
    }

    public void onStart(Intent paramIntent, int paramInt)
    {
      super.onStart(paramIntent, paramInt);
      String str1 = paramIntent.getAction();
      if (str1 == null);
      while (true)
      {
        return;
        loadUser();
        AppWidgetManager localAppWidgetManager = AppWidgetManager.getInstance(this);
        ComponentName localComponentName1 = WeiboWidgetProvider.THIS_WIDGET;
        int[] arrayOfInt = localAppWidgetManager.getAppWidgetIds(localComponentName1);
        if ((arrayOfInt == null) || (arrayOfInt.length == 0))
        {
          int i = Log.d("weibo", "appWidgetIds is null or appWidgetIds.length == 0");
          continue;
        }
        if (mUser == null)
          loadUser();
        if ((mUser == null) || (str1.equals("com.sina.weibo.service.action.ACTION_LOGIN")))
        {
          Utils.logd("No user logged in ---- Widget");
          RemoteViews localRemoteViews1 = initLoginViews();
          AppWidgetManager.getInstance(this).updateAppWidget(arrayOfInt, localRemoteViews1);
          continue;
        }
        if (str1.equals("com.sina.weibo.service.action.ACTION_LOADING"))
        {
          RemoteViews localRemoteViews2 = initProgressViews();
          AppWidgetManager.getInstance(this).updateAppWidget(arrayOfInt, localRemoteViews2);
          new WeiboWidgetProvider.WeiboWidgetService.4(this, arrayOfInt).start();
          if (this.handlerRunning)
            continue;
          boolean bool = this.handler.sendEmptyMessageDelayed(900, 7000L);
          continue;
        }
        if (str1.equals("com.sina.weibo.service.action.ACTION_UP_BLOG"))
        {
          makeUpAction(arrayOfInt);
          continue;
        }
        if (str1.equals("com.sina.weibo.service.action.ACTION_DOWN_BLOG"))
        {
          makeDownAction(arrayOfInt);
          continue;
        }
        if (!"com.sina.weibo.service.action.ACTION_REFRESH_CACHE".equals(str1))
          continue;
        String str2 = mCacheDir;
        User localUser = mUser;
        if (Utils.loadHomeListFile(str2, localUser) == null)
        {
          String str3 = String.valueOf(mUser.nick);
          Utils.logd(str3 + "'s blog list was empty, need to start MainActivity ---- Widget");
          Intent localIntent1 = new Intent();
          Context localContext1 = getApplicationContext();
          Intent localIntent2 = localIntent1.setClass(localContext1, MainTabActivity.class).addFlags(268435456);
          startActivity(localIntent2);
          continue;
        }
        Intent localIntent3 = new Intent();
        Context localContext2 = getApplicationContext();
        Intent localIntent4 = localIntent3.setClass(localContext2, WeiboWidgetService.class).setAction("com.sina.weibo.service.action.ACTION_LOADING");
        ComponentName localComponentName2 = startService(localIntent4);
      }
    }
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     com.sina.weibo.WeiboWidgetProvider
 * JD-Core Version:    0.6.0
 */